<?php
/**
 * Created by PhpStorm.
 * User: 63430
 * Date: 2018/10/27
 * Time: 21:36
 */

namespace app\admin\validate;


use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'username|管理员账户' => 'require|alphaNum',
        'password|密码' => 'require',
        'confirm|确认密码'=>'require|confirm:password',
        'nickname|昵称' => 'require|unique:admin',
        'email|邮箱' => 'require|email',
        'codein|验证码' => 'require'
    ];

    protected $message = [
      'confirm.confirm' => '两次输入密码不一致'
    ];

    public function sceneLogin(){
        return $this->only(['username','password']);
    }

    public function sceneRegister(){
        return $this->only(['username','password','confirm','nickname','email'])
            ->append('username','unique:admin')
            ->append('email','unique：admin');
    }

    public function sceneForget(){
        return $this->only(['email']);
    }

    public function sceneReset(){
        return $this->only(['codein']);
    }

    public function scenePassword(){
        return $this->only(['password','confirm']);
    }
}